ActionScripts

Allaire HomeSite 4.0 users can create ActionScripts for HomeSite that automate HomeSite tasks. These ActionScripts work like macros. They are created using VBScript or JavaScript. Information on creating the ActionScripts can be found in the Help Reference "Visual Tools Object Model" in the HomeSite help system.

Important: the internal scripting feature requires Microsoft's ActiveScripting engine v3.1 or later, which is not installed by HomeSite. If you have Microsoft Internet Explorer 4.0 or later on your system, then you already have the correct ActiveScripting engine installed. Otherwise, you'll need to download it from Microsoft.

You do not have to be able to create ActionScripts to be able to use them. You can use ActionScripts created by others. The Allaire Developer Exchange located in the Allaire DevCenter has ActionScripts that you can use. Two ActionScripts are included here to give you an idea of how this works:

"URLFormat" was created by Joel Mueller, an avid HomeSite user. This ActionScripts searches through a text document and automatically creates anchor tags for all links included in the page. It helps when you cut and paste plain text from some other tool that contains many links. With the click of one button, all the anchor tags needed will be created. So www.allaire.com becomes www.allaire.com.

"editlinkedfile" was created by Christopher Bradford, HomeSite power user and Team Allaire member. Place your cursor on an anchor tag, click on the button for this script and HomeSite will automatically open the target file for you in the Edit View.

Start by placing the URLFormat and editlinkedfile JavaScript files in the HomeSite directory. The location is not important, but some users create a directory entitled "Scripts".

To run an ActionScript, you'll need to create a custom toolbutton in order to execute it from within the program. To do this, select "Customize" from the "Options" menu and switch to the "Toolbar" page. It's a good idea to create a separate toolbar just for your custom scripts, so click the "Add Toolbar" button to create a new toolbar, giving it a name such as "Custom Scripts." Next, click "Add Custom Button," and select the "Execute an ActiveScript file" option. Then just select the external script file, and give the toolbutton a unique caption or image.

Now that you've created both the custom toolbar and toolbutton, make sure that the toolbar will be displayed by placing a checkmark next to it in the list of available toolbars on the Customization dialog. That's it - you now have a toolbutton that will execute a script file.

If the scripting engine encounters an error while executing your custom script, the script file will be opened in the editor and the offending line will be selected. In addition, information about the error will be displayed in the status bar, helping you to debug the problem.